package me.jollyfly.jshop.common.bean




import java.io.Serializable

/**
 * @author jollyfly
 */

open class ResultBean<T>  (var data: T?): Serializable {

    var msg = "success"

    var code = SUCCESS

    constructor():this(null)

    constructor(data: T?, code: Int, msg: String) : this(data){
        this.msg = msg
        this.code = code
    }


    companion object {
        private const val serialVersionUID = 1L

        val SUCCESS = 0

        val FAIL = 1

        val NO_PERMISSION = 2
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (other !is ResultBean<*>) return false

        if (data != other.data) return false
        if (msg != other.msg) return false
        if (code != other.code) return false

        return true
    }

    override fun hashCode(): Int {
        var result = data?.hashCode() ?: 0
        result = 31 * result + msg.hashCode()
        result = 31 * result + code
        return result
    }

    override fun toString(): String {
        return "ResultBean(data=$data, msg='$msg', code=$code)"
    }


}
